package day07;

public class BubbleSort {
    public static void main(String[] args) {
        int [] arr = new int[]{9,23,-23,98,0,73,45,98};
        System.out.println("排序之前的数组顺序：");
        for (int i=0;i<arr.length;i++){
            System.out.print(arr[i]+"\t");
        }

        int temp;
        for (int k=0;k<arr.length;k++){
            int len=arr.length;
            for (int i=0,j=1;j<len;i++,j++){
                if (arr[i]>arr[j]){
                    temp=arr[i];
                    arr[i]=arr[j];
                    arr[j]=temp;
                }
            }
            len-=1;
        }

        System.out.println("\n排序之后的数组顺序：");
        for (int i=0;i<arr.length;i++){
            System.out.print(arr[i]+"\t");
        }
    }
}
